<template>
  <div class="home">
    用户{{user}}登陆成功
  </div>
</template>

<script>
// @ is an alias to /src
import axios from 'axios'
export default {
  name: 'Home',
  data() {
    return {
      user:'ss'
    }
  },
  components: {
  },
  created() {
    this.getToken()
  },
  methods: {
    getToken(){
      const token=window.sessionStorage.getItem('loginuser')
      console.log(token);
      axios.defaults.headers.common['Authorization'] = token;
      axios.get('http://localhost:3009/api/profile').then(res=>{
        this.user=res.data.username
      })
    }
  },
}
</script>
